'Imports System.Web
'Imports System.Web.UI
'Imports System.Web.UI.WebControls
'Imports System.Web.UI.HtmlControls

'<ToolboxData("<{0}:PopupDialog runat=server><Content></Content><Buttons></Buttons></{0}:PopupDialog>")> _
'Public Class PopupDialog
'    Inherits jObjectiveControl

'    Private m_ctlCloseButtonImage As Image
'    Private m_ctlTitleBox As Panel
'    Private m_ctlTitleLabel As Label

'    Private m_ctlContentsContainer As Panel
'    Private m_ctlContentsTemplate As ITemplate

'    Private m_ctlButtonsContainer As Panel
'    Private m_ctlButtonsTemplate As ITemplate

'    Private m_ctlModalPopupExtender As AjaxControlToolkit.ModalPopupExtender

'    Private m_sCSSClass As String = String.Empty

'    Public Sub New()
'        MyBase.New()

'        CSSClass = "PopupBox"
'        Style("display") = "none"

'        m_ctlCloseButtonImage = New Image
'        With m_ctlCloseButtonImage
'            .AlternateText = "Close"
'            .ImageUrl = "~/style/images/close.gif"
'            .CssClass = "PopupCloseButton"
'        End With

'        m_ctlTitleBox = New Panel
'        With m_ctlTitleBox
'            .CssClass = "PopupTitleBox"
'        End With

'        m_ctlTitleLabel = New Label

'        m_ctlContentsContainer = New Panel
'        With m_ctlContentsContainer
'            .CssClass = "PopupContents"
'        End With

'        m_ctlButtonsContainer = New Panel
'        With m_ctlButtonsContainer
'            .CssClass = "PopupButtonArea"
'        End With

'        m_ctlModalPopupExtender = New AjaxControlToolkit.ModalPopupExtender
'        With m_ctlModalPopupExtender
'            .BackgroundCssClass = "ModalBackground"
'            .DropShadow = False
'        End With
'    End Sub

'    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
'        MyBase.RenderBeginTag(writer)

'        With m_ctlCloseButtonImage
'            .RenderControl(writer)
'        End With

'        With m_ctlTitleBox
'            .RenderControl(writer)
'        End With

'        m_ctlContentsContainer.RenderControl(writer)
'        m_ctlButtonsContainer.RenderControl(writer)

'        With m_ctlModalPopupExtender
'            .TargetControlID = m_ctlCloseButtonImage.ID
'            .PopupControlID = ID
'            .PopupDragHandleControlID = m_ctlTitleBox.ID
'            .RenderControl(writer)
'        End With

'        MyBase.RenderEndTag(writer)
'    End Sub

'    Protected Overrides Sub CreateChildControls()
'        Controls.Clear()

'        m_ctlTitleBox.Controls.Add(m_ctlTitleLabel)

'        If m_ctlContentsTemplate IsNot Nothing Then
'            m_ctlContentsTemplate.InstantiateIn(m_ctlContentsContainer)
'        End If

'        If m_ctlButtonsTemplate IsNot Nothing Then
'            m_ctlButtonsTemplate.InstantiateIn(m_ctlButtonsContainer)
'        End If

'        Controls.Add(m_ctlCloseButtonImage)
'        Controls.Add(m_ctlTitleBox)
'        Controls.Add(m_ctlContentsContainer)
'        Controls.Add(m_ctlButtonsContainer)
'        Controls.Add(m_ctlModalPopupExtender)

'        ChildControlsCreated = True
'    End Sub

'    <TemplateInstance(TemplateInstance.Single)> _
'    <PersistenceMode(PersistenceMode.InnerDefaultProperty)> _
'    Public Property Content() As ITemplate
'        Get
'            Return m_ctlContentsTemplate
'        End Get
'        Set(ByVal value As ITemplate)
'            m_ctlContentsTemplate = value
'        End Set
'    End Property

'    <TemplateInstance(TemplateInstance.Single)> _
'    <PersistenceMode(PersistenceMode.InnerProperty)> _
'    Public Property Buttons() As ITemplate
'        Get
'            Return m_ctlButtonsTemplate
'        End Get
'        Set(ByVal value As ITemplate)
'            m_ctlButtonsTemplate = value
'        End Set
'    End Property

'    Public Property Title() As String
'        Get
'            Return m_ctlTitleLabel.InnerHtml
'        End Get
'        Set(ByVal value As String)
'            m_ctlTitleLabel.InnerHtml = value
'        End Set
'    End Property

'    Public ReadOnly Property TitleLabel() As Label
'        Get
'            Return m_ctlTitleLabel
'        End Get
'    End Property

'    Public Property OkControlID() As String
'        Get
'            Return m_ctlModalPopupExtender.OkControlID
'        End Get
'        Set(ByVal value As String)
'            m_ctlModalPopupExtender.OkControlID = value
'        End Set
'    End Property

'    Public Property CancelControlID() As String
'        Get
'            Return m_ctlModalPopupExtender.CancelControlID
'        End Get
'        Set(ByVal value As String)
'            m_ctlModalPopupExtender.CancelControlID = value
'        End Set
'    End Property

'    Public Property TargetControlID() As String
'        Get
'            Return m_ctlModalPopupExtender.TargetControlID
'        End Get
'        Set(ByVal value As String)
'            m_ctlModalPopupExtender.TargetControlID = value
'        End Set
'    End Property

'    Public Property BehaviourID() As String
'        Get
'            Return m_ctlModalPopupExtender.BehaviorID
'        End Get
'        Set(ByVal value As String)
'            m_ctlModalPopupExtender.BehaviorID = value
'        End Set
'    End Property

'    Public Property OnOkScript() As String
'        Get
'            Return m_ctlModalPopupExtender.OnOkScript
'        End Get
'        Set(ByVal value As String)
'            m_ctlModalPopupExtender.OnOkScript = value
'        End Set
'    End Property

'    Public Property OnCancelScript() As String
'        Get
'            Return m_ctlModalPopupExtender.OnCancelScript
'        End Get
'        Set(ByVal value As String)
'            m_ctlModalPopupExtender.OnCancelScript = value
'        End Set
'    End Property

'    Public Overrides Property CSSClass() As String
'        Get
'            Return m_sCSSClass
'        End Get
'        Set(ByVal value As String)
'            m_sCSSClass = value

'            'Update control
'            MyBase.CssClass = "PopupBox " & m_sCSSClass
'        End Set
'    End Property

'    Public ReadOnly Property ContentsTemplateContainer() As Panel
'        Get
'            Return m_ctlContentsContainer
'        End Get
'    End Property

'    Public ReadOnly Property ButtonsTemplateContainer() As Panel
'        Get
'            Return m_ctlButtonsContainer
'        End Get
'    End Property

'    Public Property CloseCssClass() As String
'        Get
'            Return m_ctlCloseButtonImage.CssClass
'        End Get
'        Set(ByVal value As String)
'            m_ctlCloseButtonImage.CssClass = value
'        End Set
'    End Property

'    Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
'        BehaviourID = ID

'        Dim objTargetControl As Web.UI.Control = Parent.FindControl(TargetControlID)
'        If TypeOf objTargetControl Is Web.UI.HtmlControls.HtmlControl Then
'            DirectCast(objTargetControl, Web.UI.HtmlControls.HtmlControl).Attributes("onclick") += String.Format("jObjective.PopupDialog.Layout('{0}');", BehaviourID)
'        ElseIf TypeOf objTargetControl Is Web.UI.WebControls.WebControl Then
'            DirectCast(objTargetControl, Web.UI.WebControls.WebControl).Attributes("onclick") += String.Format("jObjective.PopupDialog.Layout('{0}');", BehaviourID)
'        End If

'        m_ctlCloseButtonImage.Attributes("onclick") = String.Format("$get($find('{0}').get_CancelControlID()).click();", BehaviourID)
'    End Sub
'End Class